package com.example.lenovo.appstore.activity;

import android.os.Bundle;

import com.example.lenovo.appstore.adapter.AllTypeRankListAdapter;
import com.example.lenovo.appstore.adapter.HomeAppListAdapter;
import com.example.lenovo.appstore.adapter.RankListAdapter;
import com.example.lenovo.appstore.utils.AppContext;
import com.example.lenovo.appstore.utils.StatusBarUtil;
import com.example.lenovo.appstore.view.TitleBarView;
import com.example.lenovo.model.CategoryListModel;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.Bind;
import butterknife.ButterKnife;

import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.example.lenovo.appstore.R;

import java.util.ArrayList;

/**
 * 三个排行列表页合一
 */


public class RankListActivity extends AppCompatActivity {
    @Bind(R.id.list)
    RecyclerView list;
    RankListAdapter adapter;
    @Bind(R.id.index_titleBar)
    TitleBarView index_titleBar;
    @Bind(R.id.top_title)
    TextView top_title;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rank_list);
        ButterKnife.bind(this);
        StatusBarUtil.immersive(this);
        StatusBarUtil.setStatusBarLightMode(getWindow());

        getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        ArrayList<CategoryListModel.CategoryList> datas = new ArrayList<>();
        for (int i = 0; i < 15; i++) {
            datas.add(new CategoryListModel.CategoryList());
        }
        adapter = new RankListAdapter(RankListActivity.this, datas);
        list.setLayoutManager(new LinearLayoutManager(RankListActivity.this));
        if (getIntent() != null) {
            int code = getIntent().getIntExtra("code", 1);
            switch (code) {
                case 1:
                    index_titleBar.setTitle(getResources().getString(R.string.category_icon1));
                    top_title.setText(getResources().getString(R.string.FreeAdmission));

                    list.setAdapter(adapter);
                    adapter.notifyDataSetChanged();
                    break;
                case 2:
                    index_titleBar.setTitle(getResources().getString(R.string.category_icon2));
                    top_title.setText(getResources().getString(R.string.PayList));
                    list.setAdapter(adapter);
                    adapter.notifyDataSetChanged();
                    break;
                case 3:
                    index_titleBar.setTitle(getResources().getString(R.string.category_icon3));
                    top_title.setText(getResources().getString(R.string.newarrival));
                    list.setAdapter(adapter);
                    adapter.notifyDataSetChanged();
                    break;
                case 4:
                    index_titleBar.setTitle(getResources().getString(R.string.category_icon4));
                    top_title.setVisibility(View.GONE);
                    AllTypeRankListAdapter adapter2 = new AllTypeRankListAdapter(RankListActivity.this, getData());
                    list.setAdapter(adapter2);
                    adapter.notifyDataSetChanged();
                    break;
            }
            adapter.setCode(code);
        }

    }

    public ArrayList<CategoryListModel.CategoryList> getData() {
        ArrayList<CategoryListModel.CategoryList> datas1 = new ArrayList<>();
        CategoryListModel.CategoryList bean1 = new CategoryListModel.CategoryList();
        bean1.setName("社交");
        bean1.setImg(R.mipmap.sj + "");
        datas1.add(bean1);
        CategoryListModel.CategoryList bean2 = new CategoryListModel.CategoryList();
        bean2.setName("购物");
        bean2.setImg(R.mipmap.gw + "");
        datas1.add(bean2);
        CategoryListModel.CategoryList bean3 = new CategoryListModel.CategoryList();
        bean3.setName("音乐");
        bean3.setImg(R.mipmap.yy + "");
        datas1.add(bean3);
        CategoryListModel.CategoryList bean4 = new CategoryListModel.CategoryList();
        bean4.setName("新闻");
        bean4.setImg(R.mipmap.xw + "");
        datas1.add(bean4);
        CategoryListModel.CategoryList bean5 = new CategoryListModel.CategoryList();
        bean5.setName("效率");
        bean5.setImg(R.mipmap.xl + "");
        datas1.add(bean5);
        CategoryListModel.CategoryList bean6 = new CategoryListModel.CategoryList();
        bean6.setName("医疗");
        bean6.setImg(R.mipmap.yl + "");
        datas1.add(bean6);
        CategoryListModel.CategoryList bean7 = new CategoryListModel.CategoryList();
        bean7.setName("商务");
        bean7.setImg(R.mipmap.sw + "");
        datas1.add(bean7);
        CategoryListModel.CategoryList bean8 = new CategoryListModel.CategoryList();
        bean8.setName("旅游");
        bean8.setImg(R.mipmap.ly + "");
        datas1.add(bean8);
        CategoryListModel.CategoryList bean9 = new CategoryListModel.CategoryList();
        bean9.setName("教育");
        bean9.setImg(R.mipmap.jy + "");
        datas1.add(bean9);
        CategoryListModel.CategoryList bean10 = new CategoryListModel.CategoryList();
        bean10.setName("摄影与录像");
        bean10.setImg(R.mipmap.sy + "");
        datas1.add(bean10);
        CategoryListModel.CategoryList bean11 = new CategoryListModel.CategoryList();
        bean11.setName("图书");
        bean11.setImg(R.mipmap.ts + "");
        datas1.add(bean11);
        return datas1;

    }
}
